<template>
<div>
  <el-container>
    <el-header>
      <Top></Top>
    </el-header>
    <el-container>
      <el-aside width="200px">
        <el-menu
          default-active="2"
          class="el-menu-vertical-demo"
          @open="handleOpen"
          @close="handleClose">
          <router-link to="/accessor-home" style="text-decoration: none;">
            <el-menu-item index="3" >
              <i class="el-icon-document"></i>
              <span slot="title">评审</span>
            </el-menu-item>
          </router-link>
          <router-link to="/assessor-vote" style="text-decoration: none;">
            <el-menu-item index="4">
              <i class="el-icon-setting"></i>
              <span slot="title">投票</span>
            </el-menu-item>
          </router-link>
        </el-menu>
      </el-aside>
      <el-main>
        <div>
          <el-card class="box-card" style="height: 80px;">
            <el-form :inline="true" :model="formInline" class="demo-form-inline">
              <el-form-item label="学号">
                <el-input v-model="formInline.user" placeholder="学号"></el-input>
              </el-form-item>
              <el-form-item>
                <el-button type="primary" @click="onSubmit">查询</el-button>
              </el-form-item>
            </el-form>
          </el-card>
        </div>
        <div style="margin-top: 15px;">
          <el-card class="box-card">
            <el-table
              :data="tableData"
              style="width: 100%"
              max-height="350">
              <el-table-column
                fixed
                prop="studentId"
                label="学号"
                align="center"
              >
              </el-table-column>
              <el-table-column
                prop="name"
                label="姓名"
                align="center"
              >
              </el-table-column>
              <el-table-column
                prop="phone"
                label="电话"
                align="center"
              >
              </el-table-column>
              <el-table-column
                prop="identityId"
                label="身份证"
                show-overflow-tooltip
                align="center"
              >
              </el-table-column>
              <el-table-column
                prop="college"
                label="学院"
                align="center"
              >
              </el-table-column>
              <el-table-column
                prop="classroom"
                label="班级"
                align="center"
              >
              </el-table-column>
              <el-table-column
                prop="greenCode"
                label="是否绿色通道"
                align="center"
              >
              </el-table-column>
              <el-table-column
                prop="file"
                label="附件"
                align="center"
              >
                <template slot-scope="scope">
                  <el-button
                    @click.native.prevent="deleteRow(scope.$index, scope.row)"
                    type="text"
                    size="small">
                    查看
                  </el-button>
                </template>
              </el-table-column>
              <el-table-column
                fixed="right"
                label="操作"
                >
                <template slot-scope="scope">
                  <el-button
                    @click.native.prevent="setYesRow(scope.$index, scope.row)"
                    type="text"
                    size="small">
                    通过
                  </el-button><el-button
                    @click.native.prevent="setNoRow(scope.$index, scope.row)"
                    type="text"
                    size="small">
                    不通过
                  </el-button>
                </template>
              </el-table-column>
            </el-table>
            <div style="margin-top: 25px;">
              <el-pagination
                :current-page="pagination.currentPage"
                :page-size="pagination.pageSize"
                :page-sizes="[5, 10, 20, 50]"
                layout="total, sizes, prev, pager, next, jumper"
                :total="pagination.total"
                @size-change="handleSizeChange"
                @current-change="handleCurrentChange"
              />
            </div>
          </el-card>

          <div>
            <el-dialog title="收货地址" :visible.sync="dialogTableVisible">
              <el-image :src="src"></el-image>
            </el-dialog>
          </div>

        </div>
      </el-main>
    </el-container>
  </el-container>
</div>
</template>

<script>
import Top from "@/components/welTop"

export default {
  name: "index",
  components: {
    Top
  } ,
  data() {
    return {
      formInline: {
        user: '',
        region: ''
      },
      entiy:{

      },
      pagination:{
        currentPage:1,
        pageSize:10,
        total:0,
      },
      tableData: [],
      dialogTableVisible: false,
      currentPage4: 4
    }
  },
  created() {
    this.getPageCommit()
  },
  methods: {
    onSubmit() {
      console.log('submit!');
    },
    setYesRow(index, rows) {
      if(rows.greenCode==="1"){
        this.$axios.post("/assessor-setFirstResult/"+rows.id+'/1').then(res=>{
          this.$message({
            message:res.data.msg,
            type:"success"
          })
        })
      }else {
        this.$axios.post("/assessor-setFirstResult/"+rows.id+'/2').then(res => {
          this.$message({
            message: res.data.msg,
            type: "success"
          })
        })
      }
    },
    setNoRow(index, rows) {
      this.$axios.post("/assessor-setFirstResult/"+rows.id+'/0').then(res=>{
        this.$message({
          message:res.data.msg,
          type:"success"
        })
      })
    },
    handleSizeChange(val) {
      console.log(`每页 ${val} 条`);
    },
    handleCurrentChange(val) {
      console.log(`当前页: ${val}`);
    },
    getPageCommit(){
      this.$axios.post('/assessor-getStudentInfo/' + this.pagination.currentPage + '/' + this.pagination.pageSize,this.entiy).then(res =>{
        if(res.data.code==0){
          this.$message({
            message:'信息查询成功',
            type:'success'
          })
          this.tableData=res.data.data.records
          this.pagination.total=res.data.data.total
          this.pagination.currentPage=res.data.data.currentPage
          this.pagination.pageSize=res.data.data.pageSize
        }else{
          this.$message.error('出错了'+res.data.msg)
        }
      }).catch(err =>{
        this.$message('异常错误：'+err)
        return Promise.reject(err)
      })
    }
  }
}
</script>

<style scoped>

</style>

<style>
.el-header, .el-footer {
  /*background-color: #B3C0D1;*/
  color: #333;
  text-align: center;
  line-height: 17px;
}

.el-aside {
  /*background-color: #D3DCE6;*/
  color: #333;
  text-align: center;
  line-height: 200px;
}

.el-main {
  background-color: #EEE;
  color: #333;
  text-align: left;
}

body > .el-container {
  margin-bottom: 40px;
}

.el-container:nth-child(5) .el-aside,
.el-container:nth-child(6) .el-aside {
  line-height: 260px;
}

.el-container:nth-child(7) .el-aside {
  line-height: 320px;
}
</style>
